//-----------------------------------------------------------------------
// <copyright file="UnitPriceService.cs" company="FetCo">
//     Copyright (c) FetCo. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using FetCo.Framework;
using ADESSA.Entities;
using ADESSA.Data;
    
namespace ADESSA.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class UnitPriceService
    {
        #region UnitPrice

        public static void CreateUnitPrice(UnitPrice unitPrice)
        {            
            try
            {
                UnitPriceDAO unitPriceDAO = new UnitPriceDAO();
                unitPriceDAO.CreateUnitPrice(unitPrice);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateUnitPriceException, ex);
            }
        }        

        public static void UpdateUnitPrice(UnitPrice unitPrice)
        {            
            try
            {
                UnitPriceDAO unitPriceDAO = new UnitPriceDAO();
                unitPriceDAO.UpdateUnitPrice(unitPrice);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateUnitPriceException, ex);
            }
        }        

        public static void DeleteUnitPrice(long unitPriceId)
        {            
            try
            {
                UnitPriceDAO unitPriceDAO = new UnitPriceDAO();
                unitPriceDAO.DeleteUnitPrice(unitPriceId);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteUnitPriceException, ex);
            }
        }
        
        public static UnitPrice GetUnitPrice(long unitPriceId)
        {            
            try
            {
                UnitPriceDAO unitPriceDAO = new UnitPriceDAO();
                return unitPriceDAO.GetUnitPrice(unitPriceId);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetUnitPriceException, ex);
            }
        }                

        public static UnitPriceCollection GetUnitPriceList(UnitPriceColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                UnitPriceDAO unitPriceDAO = new UnitPriceDAO();
                return unitPriceDAO.GetUnitPriceList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetUnitPriceListException, ex);
            }
        }        

        public static UnitPriceCollection GetUnitPriceList(UnitPriceColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                UnitPriceDAO unitPriceDAO = new UnitPriceDAO();
                return unitPriceDAO.GetUnitPriceList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetUnitPriceListException, ex);
            }
        }        

	    public static UnitPriceCollection GetUnitPriceListByParam(object orderBy, OrderDirection orderDirection,string where)
        {            
            try
            {
                UnitPriceDAO unitPriceDAO = new UnitPriceDAO();
                return unitPriceDAO.GetUnitPriceListByParam(orderBy, orderDirection,where);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetUnitPriceListException, ex);
            }
        }        

        public static UnitPriceCollection GetUnitPriceListByParam(object orderBy, OrderDirection orderDirection, int page, int pageSize,string Criteria, out int totalRecords)
        {            
            try
            {
                UnitPriceDAO unitPriceDAO = new UnitPriceDAO();
                return unitPriceDAO.GetUnitPriceListByParam(orderBy, orderDirection, page, pageSize,Criteria, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetUnitPriceListException, ex);
            }
        }        

        #endregion
    }
}